package gameMechanics;

import static org.junit.Assert.*;

import java.util.Collections;

import org.junit.Test;


public class DeckTest {
	private Deck testDeck1;
	private Deck testDeck2;
	private BoardCards testBoardCards;
	private Player testPlayer1;
	private Player testPlayer2;
	private Player testPlayer3;
	
	public Deck createDeck(){
		return new Deck();
	}
	public BoardCards createBoardCards(){
		return new BoardCards();
	}
	public PocketCards createPocketCards(){
		return new PocketCards();
	}
	public Player createPlayer(int seat, int bankroll){
		return new Player(seat, bankroll);
	}
	@Test
	public void DeckSizeTest(){
		testDeck1 = createDeck();
		int i = testDeck1.getDeckState().size();
		System.out.println(i);
		assertTrue(testDeck1.getDeckState().size() == 52);
	}
	@Test
	public void DeckRandomShuffleTest(){
		testDeck1 = createDeck();
		testDeck2 = createDeck();
		assertTrue(testDeck1 != testDeck2);
	}
	@Test
	public void DeckStateTest(){
		testDeck1 = createDeck();
		testDeck2 = createDeck();
		System.out.println(testDeck1.getDeckState());
		Collections.shuffle(testDeck2.getDeckState());
		System.out.println(testDeck2.getDeckState());
		testDeck1.dealCard();
		assertTrue(testDeck1.getDeckState().size() != testDeck2.getDeckState().size());
	}
	@Test
	public void DealCardTest(){
		testDeck1 = createDeck();
		System.out.println(testDeck1.getDeckState());
		System.out.println(testDeck1.getDeckState().size());
		testBoardCards = createBoardCards();
		System.out.println(testBoardCards.getTableCards());
		System.out.println(testBoardCards.getPlayerPocketCards());
		testBoardCards.addDealtCardToTableCards(testDeck1.dealCard());
		testBoardCards.addDealtCardToTableCards(testDeck1.dealCard());
		testBoardCards.addDealtCardToTableCards(testDeck1.dealCard());
		testBoardCards.addDealtCardToTableCards(testDeck1.dealCard());
		testBoardCards.addDealtCardToTableCards(testDeck1.dealCard());
		System.out.println(testDeck1.getDeckState());
		System.out.println(testBoardCards.getTableCards());
		testPlayer1 = createPlayer(1, 500);
		testPlayer2 = createPlayer(2, 500);
		testPlayer3 = createPlayer(3, 500);
		testBoardCards.addPlayerHandtoPlayerPocketCardList(testPlayer1.getPlayerPocketCards());
		testBoardCards.addPlayerHandtoPlayerPocketCardList(testPlayer2.getPlayerPocketCards());
		testBoardCards.addPlayerHandtoPlayerPocketCardList(testPlayer3.getPlayerPocketCards());
		testPlayer1.DealCardToPlayerHand(testDeck1.dealCard());
		testPlayer1.DealCardToPlayerHand(testDeck1.dealCard());
		testPlayer2.DealCardToPlayerHand(testDeck1.dealCard());
		testPlayer2.DealCardToPlayerHand(testDeck1.dealCard());
		testPlayer3.DealCardToPlayerHand(testDeck1.dealCard());
		testPlayer3.DealCardToPlayerHand(testDeck1.dealCard());
		System.out.println(testDeck1.getDeckState().size());
		System.out.println(testPlayer1.getPlayerPocketCards().getPlayerHand().get(0));
		System.out.println(testPlayer1.getPlayerPocketCards().getPlayerHand().get(1));
		System.out.println(testPlayer2.getPlayerPocketCards().getPlayerHand().get(0));
		System.out.println(testPlayer2.getPlayerPocketCards().getPlayerHand().get(1));
		System.out.println(testPlayer3.getPlayerPocketCards().getPlayerHand().get(0));
		System.out.println(testPlayer3.getPlayerPocketCards().getPlayerHand().get(1));
		assertTrue(testDeck1.getDeckState().size() == 41);
	}
	@Test
	public void CreateNextDeckTest(){
		testDeck1 = createDeck();
		testBoardCards = createBoardCards();
		testBoardCards.addDealtCardToTableCards(testDeck1.dealCard());
		testBoardCards.addDealtCardToTableCards(testDeck1.dealCard());
		testBoardCards.addDealtCardToTableCards(testDeck1.dealCard());
		testBoardCards.addDealtCardToTableCards(testDeck1.dealCard());
		System.out.println(testBoardCards.checkBoardCards());
		testPlayer1 = createPlayer(1, 500);
		testPlayer2 = createPlayer(2, 500);
		testPlayer3 = createPlayer(3, 500);
		testPlayer1.DealCardToPlayerHand(testDeck1.dealCard());
		testPlayer1.DealCardToPlayerHand(testDeck1.dealCard());
		testPlayer2.DealCardToPlayerHand(testDeck1.dealCard());
		testPlayer2.DealCardToPlayerHand(testDeck1.dealCard());
		testPlayer3.DealCardToPlayerHand(testDeck1.dealCard());
		testPlayer3.DealCardToPlayerHand(testDeck1.dealCard());
		System.out.println(testBoardCards.checkBoardCards());
		testBoardCards.addPlayerHandtoPlayerPocketCardList(testPlayer1.getPlayerPocketCards());
		testBoardCards.addPlayerHandtoPlayerPocketCardList(testPlayer2.getPlayerPocketCards());
		testBoardCards.addPlayerHandtoPlayerPocketCardList(testPlayer3.getPlayerPocketCards());
		testDeck1.getDeckState().clear();
		System.out.println(testDeck1.getDeckState());
		System.out.println(testBoardCards.checkBoardCards());
		testBoardCards.addDealtCardToTableCards(testDeck1.dealCard());
		System.out.println(testBoardCards.checkBoardCards());
		assertTrue(testDeck1.getDeckState().size() == 41);
	}
}
